const CopyWebpackPlugin = require('copy-webpack-plugin');
const cssAppend = require('./css.append.js');
const we7Append = require('./we7.append.js');
const removeOtiose = require('./remove.otiose.js');
const noPlugins = require('./no.plugins.js');
const path = require('path');

module.exports = {
	configureWebpack: {
		plugins: [
			new CopyWebpackPlugin([{
					from: path.join(__dirname, 'src/siteinfo.js'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, '')
				},
				{
					from: path.join(__dirname, 'src/version.js'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, '')
				},
				{
					from: path.join(__dirname, 'src/sitemap.json'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, '')
				},
				{
					from: path.join(__dirname, 'src/siteinfo.js'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'plugins/integral_mall/siteinfo.js')
				},
				{
					from: path.join(__dirname, 'src/siteinfo.js'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'plugins/pt/siteinfo.js')
				},
				{
					from: path.join(__dirname, 'src/siteinfo.js'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'pages/siteinfo.js')
				},
				{
					from: path.join(__dirname, 'src/siteinfo.js'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'pages/order/siteinfo.js')
				},
				{
					from: path.join(__dirname, 'src/pages/address/json/name.json'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'pages/address/json/name.json')
				},
				{
					from: path.join(__dirname, 'src/pages/goods/image'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'pages/goods/image')
				},
				/* {
					from: path.join(__dirname, 'src/plugins/goods/image'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'plugins/goods/image')
				}, */
				{
					from: path.join(__dirname, 'src/plugins/mch_solitaire/image'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'plugins/mch_solitaire/image')
				},
				{
					from: path.join(__dirname, 'src/plugins/mch_solitaire/cats/image'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'plugins/mch_solitaire/cats/image')
				},
				{
					from: path.join(__dirname, 'src/plugins/mch_solitaire/clerk/image'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'plugins/mch_solitaire/clerk/image')
				},
				{
					from: path.join(__dirname, 'src/pages/favorite/image'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'pages/favorite/image')
				},
				{
					from: path.join(__dirname, 'src/pages/foot/image'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'pages/foot/image')
				},
				{
					from: path.join(__dirname, 'src/pages/share/image'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'pages/share/image')
				},
				{
					from: path.join(__dirname, 'src/pages/coupon/image'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'pages/coupon/image')
				},
				{
					from: path.join(__dirname, 'src/pages/search/image'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'pages/search/image')
				},
				{
					from: path.join(__dirname, 'src/plugins/pond/image'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'plugins/pond/image')
				},
				{
					from: path.join(__dirname, 'src/plugins/pt/image'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'plugins/pt/image')
				},
				{
					from: path.join(__dirname, 'src/plugins/integral_mall/image'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'plugins/integral_mall/image')
				},
				{
					from: path.join(__dirname, 'src/plugins/clerk/image'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'plugins/clerk/image')
				},
				{
					from: path.join(__dirname, 'src/plugins/check_in/image'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'plugins/check_in/image')
				},
				{
					from: path.join(__dirname, 'src/plugins/demo/static'),
					to: path.join(__dirname, 'dist', process.env.NODE_ENV === 'production' ? 'build' :
						'dev', process.env.UNI_PLATFORM, 'plugins/demo/static')
				},
			]),
			cssAppend,
			we7Append,
			removeOtiose,
			noPlugins,
		],
		externals: {
			'siteInfo': 'commonjs2 ../siteinfo.js',
			'appVersion': 'commonjs2 ../version.js',
		}
	}
};
